﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ETADTools.Lib
{
  public static class Constant
  {
    private static long sortOrder = 0;

    /// <summary>
    /// Sort order
    /// </summary>
    public static string SortOrder
    {
      get
      {
        sortOrder = sortOrder + 10;
        return sortOrder.ToString();
      }
    }
  }

  public static class Helper
  {
    public static string GetNextNumber(string folder)
    {
      int number = 0;

      // Get all files in the folder
      string[] files = Directory.GetFiles(folder);

      // At least one file exists ...
      if (files.Length > 0)
      {
        // Get the last file (sorted by Name)
        string lastFile = Path.GetFileName(files[files.Length - 1]);

        // Get the number (sort order) from the latest file
        int.TryParse(lastFile.Substring(0, 4), out number);
      }

      // Get the next number with format "0000" i.e. 0030
      return string.Format("{0:0000}", number + 10);
    }
  }

  /// <summary>
  /// Static structure of Updater
  /// </summary>
  public static class ETWebPath
  {
    public static string FrontEnd = @"FRONTEND\";
    public static string DataPages = @"FRONTEND\DataPages\";

    public static string BackEnd = @"BACKEND\";
    public static string Table = @"BACKEND\2-Table\";
    public static string View = @"BACKEND\3-View\";
    public static string SP = @"BACKEND\4-SP\";
    public static string Data = @"BACKEND\5-Data\";
    public static string Other = @"BACKEND\6-Other\";
  }
}
